﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace comm_num_tp1
{
    public class GpGSVList : GpsStream, IEnumerator
    {
        #region private variables
        private GpGSV[] _myGpGSVlist;
        private int _gpgsvArray = -1;
        #endregion

        #region Constructor
        public GpGSVList()
        {
            this.Count = 0;
            IsGsvList = true;
        }
        #endregion
        #region accessor
        public object Current
        {
            get
            {
                return _myGpGSVlist[_gpgsvArray];
            }
        }
        public GpGSV this[int n]
        {
            get
            {
                if (n >= 0 && n < _myGpGSVlist.Length)
                    return _myGpGSVlist[n];
                else
                    return null;
            }


        }
        public int Count { get; set; }
        #endregion

        #region public methods
        public IEnumerator GetEnumerator()
        {
            return this;
        }

        public bool MoveNext()
        {
            _gpgsvArray++;
            if (_gpgsvArray < _myGpGSVlist.Length)
                return true;
            else
                return false;
        }

        public void Reset()
        {
            _gpgsvArray = -1;
        }

        public void AddSateliteSet(GpGSV gsvSet)
        {
            if (_myGpGSVlist == null)
            {
                _myGpGSVlist = new GpGSV[1];
                _myGpGSVlist[0] = gsvSet;
            }
            else
            {
                GpGSV[] gsvTemp = _myGpGSVlist;
                _myGpGSVlist = new GpGSV[gsvTemp.Length + 1];
                for (int i = 0; i < gsvTemp.Length; i++)
                    _myGpGSVlist[i] = gsvTemp[i];
                _myGpGSVlist[gsvTemp.Length] = gsvSet;
            }
            Count++;
        }

        public void RemoveAllGsvSet()
        {
            _myGpGSVlist = null;
            Count = 0;
        }
        #endregion
    }
}
